package com.wenchao.jetpackdemo.dataBinding

import android.app.Activity
import android.util.Log
import android.view.View
import android.widget.Toast
import androidx.databinding.BaseObservable
import androidx.databinding.ObservableField

/**
 * 【类的描述】介绍一下该类的用途
 * @author zhangwenchao
 * @date 2021-12-25
 */
class TwoWayBindingViewModel : BaseObservable() {

    val username = ObservableField<String>()
    val password = ObservableField<String>()

    init {
        username.set("hello")
        password.set("world")
    }

    fun login(view: View) {
        Log.d("super", "username = " + username.get())
        Log.d("super", "password = " + password.get())
        val context: Activity = view.context as Activity
        Toast.makeText(context, "登录成功！", Toast.LENGTH_SHORT).show()
        context.finish()
    }

}